#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

# Acha vários números A onde sqrt(1 + 4*A) é racional
#ok = set()
#for i in range(1, 30):
#    for j in range(1, 30):
#        x = sqrt(1 + (Four * i) / j)
#        if isinstance(x, Rational):
#            ok.add(One * i / j)
#ok = list(ok)
#ok.sort()
#print ', '.join('One * %s' % x for x in ok)

while True:
    with display_block('Entradas'):
        A = oneof(One * 6 / 25, One * 5 / 16, One * 4 / 9, One * 14 / 25,
                  One * 3 / 4, One * 24 / 25, One * 10 / 9, One * 21 / 16, One * 2,
                  One * 28 / 9, One * 15 / 4, One * 6, One * 12, One * 20)
        sqrA = sqrt(1 + 4 * A)
        rho = sqrt(1 + 4 * A) / 2 - Half

    with display_block('Saídas'):
        # exige termo simples
        aux = 3 - 2 * sqrA + 4 * A
        if not(isinstance(sqrt(aux), Rational) or isinstance(sqrt(2 * aux), Rational)):
            continue

        cima = -(One / 6) * pi + (One / 6) * pi * aux ** (Three / 2)
        cone = (sqrt(2) / 4) * pi * (sqrA - 1) ** 2
        area = cima + cone
        parabPlano = -(One / 6) * pi + (One / 6) * pi * (1 + 4 * A) ** (Three / 2)
        supArea = 2 * pi * rho ** 2
        parabPlanoJacob = pi * A
        soma = ((1 + sqrt(2)) * pi * rho ** 2).expand()

        if len(set([cima, cone, area, parabPlano, supArea, parabPlanoJacob, soma])) != 7:
            continue
    break
